<?php Temp::Tinclude("commom/admin_header");?>
 <div class="padding_left_right">
<div class="panel panel-default">
  <div class="panel-heading">编辑菜单</div>
  <div class="panel-body">
     
      <form class="form" role="form" action="index.php?<?php echo $jp_arg['c'];?>/<?php echo $jp_arg['a'];?>"  method="post">    
          <input type="hidden" value="<?php echo $id;?>" name="id" />
<div class="form-group input-group col-md-6">
   
    <span class="input-group-addon" id="basic-addon1">菜单名称:</span>
    <input type="text" value="<?php echo $menu['base_name'];?>" name="base_name" class="form-control" placeholder="名称" aria-describedby="basic-addon1">

</div>
   
 <div class="form-group  form-inline menuparent">
     <?php foreach($pinfo as $k=>$val){?>
     <?php if($k==0){?>
     <select class="form-control  parent_id" <?php if(count($pinfo)==1)echo "name='parent_id'";?>>
      <option value="0">顶级分类</option>
 
          <?php foreach($val["data"] as $value){?>
         
          <option value="<?php echo $value['id'];?>" <?php if($value["id"]==$val["selected"]) echo "selected";?> ><?php echo $value['base_name'];?></option>
        
  
         <?php }?>
  </select>
     <?php }else{?>
     <span class="menuchildrenall">  
         <select class="form-control  menuchildren"  onchange="menuselectchange(this)" <?php if($k==count($pinfo)-1)echo "name='parent_id'";?>>
          <option value="-1">请选择分类</option>
    
          <?php foreach($val["data"] as $value){?>
           <option value="<?php echo $value['id'];?>" <?php if($value["id"]==$val["selected"]) echo "selected";?> ><?php echo $value['base_name'];?></option>
          <?php }?>
       
         
  </select>

</span>
     <?php }?>
     <?php }?>

     
     
 </div>
         
         
         <div class="form-group input-group col-md-4">
   
    <span class="input-group-addon" id="basic-addon1">控制器名称:</span>
    <input type="text"  name="c"  value="<?php echo $menu['c'];?>" class="form-control" placeholder="控制器" aria-describedby="basic-addon1">

</div>
         
         <div class="form-group input-group col-md-4">
   
    <span class="input-group-addon" id="basic-addon1">方法名称:</span>
    <input type="text" name="a" class="form-control"  value="<?php echo $menu['a'];?>" placeholder="方法" aria-describedby="basic-addon1">

</div>
<div class="form-group input-group col-md-1">
   
    <span class="input-group-addon" id="basic-addon1">排序:</span>
    <input type="text" name="sort" class="form-control"  value="<?php echo $menu['sort'];?>" placeholder="排序" aria-describedby="basic-addon1">

</div>
          
     <div class="form-group input-group col-md-4">     
     
<label class="radio-inline">
  <input type="radio" name="is_display" id="inlineRadio1" value="1"  <?php if($menu['is_display'])echo "checked";?> > 显示菜单
</label>
<label class="radio-inline">
  <input type="radio" name="is_display" id="inlineRadio2" value="0" <?php if(!$menu['is_display'])echo "checked";?>> 不显示菜单
</label>
      </div>
          
          
           <div class="form-group input-group col-md-4">
            <input class="btn btn-default" type="submit" name="submit" value="提交">
           </div>




  </form>
     
  </div>
</div>

<script>
    function menuselectchange(obj){
             var cid=$(obj).val();

             
         
             var thisobj=$(obj).parent();
                if(cid>0){
                  $(".menuchildren").attr("name","");
                  $(".parent_id").attr("name","");
                  $(obj).attr("name","parent_id");
              
                  $.post("?menu/public_get_children",{"parent_id":cid,"curid":<?php echo $id;?>},function(data){
                  $(".menuchildrenall").each(function(){
                      if($(this).index()>thisobj.index()){
                          $(this).remove();
                      }
                  });
                  text=data.replace(/(^\s*)|(\s*$)/g,'');
                  if(text.length>0){
                  $(".menuparent").append(data);
                  }
                 
      });
             }

        }
    $('.parent_id').bind('change', function () {
      var cid=$(this).val();
      var parent=$(this).parent();
      $(this).attr("name","parent_id");
      if(cid!=0){
      
      $.post("?menu/public_get_children",{"parent_id":cid,"curid":<?php echo $id;?>},function(data){
          $(".menuchildrenall").remove();
          parent.append(data);
         
      });
    }else{
      
        $(".menuchildrenall").remove();
    }
    });
    
    
    
</script>
 </div>
<?php Temp::Tinclude("commom/admin_footer");?>